/**
 * @file: service.js
 * @description:
 * @author: YUWENJING
 * @date: 2020/2/16
 * @contact:wenjingyuer@126.com
 */
import Taro from "@tarojs/taro";
import {goHome, toast} from "../../../utils";
import {getGlobalData, setGlobalData} from "../../../global.d";

const db = Taro.cloud.database();
const _ = db.command

export function updateUserClass(userId, userClass,changeLastTimeClass) {
  if(!changeLastTimeClass)
  db.collection('user')
    .doc(userId)
    .update({
      data:{
        userClass
      },
      success:res => {
        toast('操作成功')
      }
    })
  else
    db.collection('user')
      .doc(userId)
      .update({
        data:{
          userClass,
          userLastTimeClass:{
            className:'【默认加入】酷班级功能展示一班',
            classKey:'00000001',
            type:'user'
          }
        },
        success:res => {
          toast('操作成功')
        }
      })

}
